1 Transects

Plant Flowers Date lon lat ele Month Year julian
Glossoloma oblongicalyx 4 2015-10-19 -78.59093 0.130838 2270 October 2015 292
Gasteranthus quitensis 2 2016-10-17 -78.59770 0.120070 1940 October 2016 291
Kohleria affinis 1 2016-12-13 -78.59534 0.126746 2110 December 2016 348
Columnea ciliata 3 2014-02-27 -78.59934 0.116682 1960 February 2014 58
Columnea medicinalis 1 2014-04-23 -78.59372 0.128700 2130 April 2014 113
Drymonia teuscheri 3 2016-07-28 -78.59245 0.129393 2200 July 2016 210

2 Phylogeny

3 Traits

Plant Flowers Date lon lat ele Month Year julian
Glossoloma oblongicalyx 4 2015-10-19 -78.59093 0.130838 2270 October 2015 292
Gasteranthus quitensis 2 2016-10-17 -78.59770 0.120070 1940 October 2016 291
Kohleria affinis 1 2016-12-13 -78.59534 0.126746 2110 December 2016 348
Columnea ciliata 3 2014-02-27 -78.59934 0.116682 1960 February 2014 58
Columnea medicinalis 1 2014-04-23 -78.59372 0.128700 2130 April 2014 113
Drymonia teuscheri 3 2016-07-28 -78.59245 0.129393 2200 July 2016 210

3.0.1 Total Flowers

3.1 Peak date

3.2 Infer absences

3.3 Species elevation ranges

4 Count model of species phenology

## sink("model/poisson_occ_elev.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
## 
##       #Observation - count
##       Y[x] ~ dpois(lambda[x])
## 
##       #Intensity is the probability of presence, species intercept and the phylogenetic covariance
##       log(lambda[x]) = z[x] * alpha[Plant[x]]
## 
##       #Probability of presence
##       z[x] ~ dbern(psi[x])
##       logit(psi[x])<- alpha2[Plant[x]] + beta[Plant[x]] * ele[x]
##       
##       #Residuals
##       discrepancy[x] <- pow(Y[x] - lambda[x],2)/lambda[x]
## 
##       #Assess Model Fit
##       Ynew[x] ~ dpois(lambda[x])
##       discrepancy.new[x]<-pow(Ynew[x] - lambda[x],2)/lambda[x]
##     
##     }
##     
##     #Sum discrepancy
##     fit<-sum(discrepancy)
##     fitnew<-sum(discrepancy.new)
## 
##     #Prediction
## 
##     for(i in 1:Npreds){
## 
##       #predict value
## 
##       #Observation - count
##       prediction[i] ~ dpois(lambda_new[i])
## 
##       #Intensity is the probability of presence, species intercept and the phylogenetic covariance
##       log(lambda_new[i]) = z_new[i] * alpha[Ypred_plant[i]]
## 
##       #Probability of presence
##       z_new[i] ~ dbern(psi_new[i])
##       logit(psi_new[i])<- alpha2[Ypred_plant[i]] + beta[Ypred_plant[i]] * ele_new[i]
## 
##       #squared predictive error
##       pred_error[i] <- pow(Ypred[i] - prediction[i],2)
##     }
## 
##     #Predictive Error
##     fitpred<-sum(pred_error)
## 
##     #Priors
##     
##     #Species level priors
##     
##     for (j in 1:Plants){
##     
##     #Intercept
##     #Intercept flowering count
##     alpha[j] ~ dnorm(0,0.0001)
## 
##     #Internet probability of presence, logit transformed
##     alpha2[j] ~ dnorm(0,0.386)
## 
##     #Effect of elevation, logit transformed
##     beta[j] ~ dnorm(0,0.386)
##     } 
##     
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 2912
##    Unobserved stochastic nodes: 6874
##    Total graph size: 52125
## 
## Initializing model

4.0.1 Evaluate convergence

4.0.2 Posterior estimates

4.0.3 Estimated occurrence

Red is the kernel density from the underlying data Black is the modeled phenology

4.0.4 Predicted occurrence

5 Phylogeny

5.1 Attraction

## sink("model/poisson_occ_elev_attraction.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation - count
##     Y[x] ~ dpois(lambda[x])
##     
##     #Intensity is the probability of presence, species intercept and the phylogenetic covariance
##     log(lambda[x]) <- z[x] * (alpha[Plant[x]] + e[Plant[x]])
##     
##     #Probability of presence
##     z[x] ~ dbern(psi[x])
##     logit(psi[x])<- alpha2[Plant[x]] + beta[Plant[x]] * ele[x]
##     
##     #Residuals
##     discrepancy[x] <- pow(Y[x] - lambda[x],2)/lambda[x]
##     
##     #Assess Model Fit
##     Ynew[x] ~ dpois(lambda[x])
##     discrepancy.new[x]<-pow(Ynew[x] - lambda[x],2)/lambda[x]
##     
##     }
##     
##     #Sum discrepancy
##     fit<-discrepancy/Nobs
##     fitnew<-discrepancy.new/Nobs
##     
##     ############
##     #Prediction
##     ############
## 
##     for(i in 1:Npreds){
##     
##     #predict value
##     
##     #Observation - count
##     prediction[i] ~ dpois(lambda_new[i])
##     
##     #Intensity is the probability of presence, species intercept and the phylogenetic covariance
##     log(lambda_new[i]) = z_new[i] * (alpha[Ypred_plant[i]] + e[Ypred_plant[i]])
##     
##     #Probability of presence
##     z_new[i] ~ dbern(psi_new[i])
##     logit(psi_new[i])<- alpha2[Ypred_plant[i]] + beta[Ypred_plant[i]] * ele_new[i]
##     
##     #squared predictive error
##     pred_error[i] <- pow(Ypred[i] - prediction[i],2)
##     }
##     
##     #Sum Predictive Error
##     fitpred<-pred_error/Npreds
##     
##     #########################
##     #autocorrelation in error
##     #########################
## 
##     e[1:Plants] ~ dmnorm(zeros[],tauC[,])
##     
##     ##covariance among similiar species
##     for(i in 1:Plants){
##     for(j in 1:Plants){
##     C[i,j] = exp(-lambda_cov * D[i,j])
##     }
##     }
##     
##     ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
##     vCov = omega*C[,] + (1-omega) * I
##     tauC=inverse(vCov*gamma)
##     
##     #Priors
##     
##     #Species level priors
##     
##     for (j in 1:Plants){
##     
##     #Intercept
##     #Intercept flowering count
##     alpha[j] ~ dnorm(0,0.0001)
##     
##     #Internet probability of presence
##     alpha2[j] ~ dnorm(0,0.0001)
##     
##     #Effect of elevation
##     beta[j] ~ dnorm(0,0.0001)
##     } 
##     
##     #Autocorrelation priors
##     gamma ~ dunif(0,20)
## 
##     #Strength of covariance decay
##     lambda_cov = 5
##     omega ~ dbeta(1,1)
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 2912
##    Unobserved stochastic nodes: 6877
##    Total graph size: 52602
## 
## Initializing model

6 Get Chains

6.0.1 Evaluate convergence

6.0.2 Posterior estimates

6.1 Estimated Occurrence

6.2 Predicted Phenology

6.3 Decay in phylogenetic attraction

6.4 Repulsion

## sink("model/poisson_occ_elev_repulsion.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation - count
##     Y[x] ~ dpois(lambda[x])
##     
##     #Intensity is the probability of presence, species intercept and the phylogenetic covariance
##     log(lambda[x]) = z[x] * (alpha[Plant[x]] + e[Plant[x]])
##     
##     #Probability of presence
##     z[x] ~ dbern(psi[x])
##     logit(psi[x])<- alpha2[Plant[x]] + beta[Plant[x]] * ele[x]
##     
##     #Residuals
##     discrepancy[x] <- pow(Y[x] - lambda[x],2)/lambda[x]
##     
##     #Assess Model Fit
##     Ynew[x] ~ dpois(lambda[x])
##     discrepancy.new[x]<-pow(Ynew[x] - lambda[x],2)/lambda[x]
##     
##     }
##     
##     #Sum discrepancy
##     fit<-discrepancy/Nobs
##     fitnew<-discrepancy.new/Nobs
##     
##     ############
##     #Prediction
##     ############
##     
##     for(i in 1:Npreds){
##     
##     #predict value
##     
##     #Observation - count
##     prediction[i] ~ dpois(lambda_new[i])
##     
##     #Intensity is the probability of presence, species intercept and the phylogenetic covariance
##     log(lambda_new[i]) = z_new[i] * (alpha[Ypred_plant[i]] + e[Ypred_plant[i]])
##     
##     #Probability of presence
##     z_new[i] ~ dbern(psi_new[i])
##     logit(psi_new[i])<- alpha2[Ypred_plant[i]] + beta[Ypred_plant[i]] * ele_new[i]
##     
##     #squared predictive error
##     pred_error[i] <- pow(Ypred[i] - prediction[i],2)
##     }
##     
##     #Sum Predictive Error
##     fitpred<-pred_error/Npreds
##     
##     #########################
##     #autocorrelation in error
##     #########################
##     
##     e[1:Plants] ~ dmnorm(zeros[],tauC[,])
##     
##     ##covariance among similiar species
##     for(i in 1:Plants){
##     for(j in 1:Plants){
##     C[i,j] = exp(-lambda_cov * D[i,j])
##     }
##     }
##     
##     ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
##     #For the sake of clarity, we would inverse again for repulsion matrix, no need since its a precision matrix
##     vCov = omega*C[,] + (1-omega) * I
##     tauC=vCov*gamma
## 
##     #Priors
##     
##     #Species level priors
##     
##     for (j in 1:Plants){
##     
##     #Intercept
##     #Intercept flowering count
##     alpha[j] ~ dnorm(0,0.0001)
##     
##     #Internet probability of presence
##     alpha2[j] ~ dnorm(0,0.0001)
##     
##     #Effect of elevation
##     beta[j] ~ dnorm(0,0.0001)
##   
##     } 
##     
##     #Autocorrelation priors
##     gamma ~ dunif(0,20)
##     
##     #Strength of covariance decay
##     lambda_cov = 5
##     omega ~ dbeta(1,1)
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 2912
##    Unobserved stochastic nodes: 6877
##    Total graph size: 52601
## 
## Initializing model

7 Get Chains

7.0.1 Evaluate convergence

7.0.2 Posterior estimates

7.1 Estimated Phenology

7.2 Predicted Phenology

7.3 Decay in phylogenetic repulsion

8 Traits

8.1 Trait Attraction

## sink("model/poisson_occ_elev_attraction.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation - count
##     Y[x] ~ dpois(lambda[x])
##     
##     #Intensity is the probability of presence, species intercept and the phylogenetic covariance
##     log(lambda[x]) <- z[x] * (alpha[Plant[x]] + e[Plant[x]])
##     
##     #Probability of presence
##     z[x] ~ dbern(psi[x])
##     logit(psi[x])<- alpha2[Plant[x]] + beta[Plant[x]] * ele[x]
##     
##     #Residuals
##     discrepancy[x] <- pow(Y[x] - lambda[x],2)/lambda[x]
##     
##     #Assess Model Fit
##     Ynew[x] ~ dpois(lambda[x])
##     discrepancy.new[x]<-pow(Ynew[x] - lambda[x],2)/lambda[x]
##     
##     }
##     
##     #Sum discrepancy
##     fit<-discrepancy/Nobs
##     fitnew<-discrepancy.new/Nobs
##     
##     ############
##     #Prediction
##     ############
## 
##     for(i in 1:Npreds){
##     
##     #predict value
##     
##     #Observation - count
##     prediction[i] ~ dpois(lambda_new[i])
##     
##     #Intensity is the probability of presence, species intercept and the phylogenetic covariance
##     log(lambda_new[i]) = z_new[i] * (alpha[Ypred_plant[i]] + e[Ypred_plant[i]])
##     
##     #Probability of presence
##     z_new[i] ~ dbern(psi_new[i])
##     logit(psi_new[i])<- alpha2[Ypred_plant[i]] + beta[Ypred_plant[i]] * ele_new[i]
##     
##     #squared predictive error
##     pred_error[i] <- pow(Ypred[i] - prediction[i],2)
##     }
##     
##     #Sum Predictive Error
##     fitpred<-pred_error/Npreds
##     
##     #########################
##     #autocorrelation in error
##     #########################
## 
##     e[1:Plants] ~ dmnorm(zeros[],tauC[,])
##     
##     ##covariance among similiar species
##     for(i in 1:Plants){
##     for(j in 1:Plants){
##     C[i,j] = exp(-lambda_cov * D[i,j])
##     }
##     }
##     
##     ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
##     vCov = omega*C[,] + (1-omega) * I
##     tauC=inverse(vCov*gamma)
##     
##     #Priors
##     
##     #Species level priors
##     
##     for (j in 1:Plants){
##     
##     #Intercept
##     #Intercept flowering count
##     alpha[j] ~ dnorm(0,0.0001)
##     
##     #Internet probability of presence
##     alpha2[j] ~ dnorm(0,0.0001)
##     
##     #Effect of elevation
##     beta[j] ~ dnorm(0,0.0001)
##     } 
##     
##     #Autocorrelation priors
##     gamma ~ dunif(0,20)
## 
##     #Strength of covariance decay
##     lambda_cov = 5
##     omega ~ dbeta(1,1)
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 2912
##    Unobserved stochastic nodes: 6877
##    Total graph size: 52758
## 
## Initializing model

9 Get Chains

9.0.1 Evaluate convergence

9.0.2 Posterior estimates

9.1 Estimated Phenology

9.2 Predicted Phenology

9.3 Decay in trait attraction

9.4 Repulsion

## sink("model/poisson_occ_elev_repulsion.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation - count
##     Y[x] ~ dpois(lambda[x])
##     
##     #Intensity is the probability of presence, species intercept and the phylogenetic covariance
##     log(lambda[x]) = z[x] * (alpha[Plant[x]] + e[Plant[x]])
##     
##     #Probability of presence
##     z[x] ~ dbern(psi[x])
##     logit(psi[x])<- alpha2[Plant[x]] + beta[Plant[x]] * ele[x]
##     
##     #Residuals
##     discrepancy[x] <- pow(Y[x] - lambda[x],2)/lambda[x]
##     
##     #Assess Model Fit
##     Ynew[x] ~ dpois(lambda[x])
##     discrepancy.new[x]<-pow(Ynew[x] - lambda[x],2)/lambda[x]
##     
##     }
##     
##     #Sum discrepancy
##     fit<-discrepancy/Nobs
##     fitnew<-discrepancy.new/Nobs
##     
##     ############
##     #Prediction
##     ############
##     
##     for(i in 1:Npreds){
##     
##     #predict value
##     
##     #Observation - count
##     prediction[i] ~ dpois(lambda_new[i])
##     
##     #Intensity is the probability of presence, species intercept and the phylogenetic covariance
##     log(lambda_new[i]) = z_new[i] * (alpha[Ypred_plant[i]] + e[Ypred_plant[i]])
##     
##     #Probability of presence
##     z_new[i] ~ dbern(psi_new[i])
##     logit(psi_new[i])<- alpha2[Ypred_plant[i]] + beta[Ypred_plant[i]] * ele_new[i]
##     
##     #squared predictive error
##     pred_error[i] <- pow(Ypred[i] - prediction[i],2)
##     }
##     
##     #Sum Predictive Error
##     fitpred<-pred_error/Npreds
##     
##     #########################
##     #autocorrelation in error
##     #########################
##     
##     e[1:Plants] ~ dmnorm(zeros[],tauC[,])
##     
##     ##covariance among similiar species
##     for(i in 1:Plants){
##     for(j in 1:Plants){
##     C[i,j] = exp(-lambda_cov * D[i,j])
##     }
##     }
##     
##     ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
##     #For the sake of clarity, we would inverse again for repulsion matrix, no need since its a precision matrix
##     vCov = omega*C[,] + (1-omega) * I
##     tauC=vCov*gamma
## 
##     #Priors
##     
##     #Species level priors
##     
##     for (j in 1:Plants){
##     
##     #Intercept
##     #Intercept flowering count
##     alpha[j] ~ dnorm(0,0.0001)
##     
##     #Internet probability of presence
##     alpha2[j] ~ dnorm(0,0.0001)
##     
##     #Effect of elevation
##     beta[j] ~ dnorm(0,0.0001)
##   
##     } 
##     
##     #Autocorrelation priors
##     gamma ~ dunif(0,20)
##     
##     #Strength of covariance decay
##     lambda_cov = 5
##     omega ~ dbeta(1,1)
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 2912
##    Unobserved stochastic nodes: 6877
##    Total graph size: 52757
## 
## Initializing model

10 Get Chains

10.0.1 Evaluate convergence

10.0.2 Posterior estimates

10.1 Estimated Occurrence

10.2 Predicted Occurrence

10.3 Decay in trait repulsion

11 Model Comparison

11.1 Alpha

11.2 E: The effect of autocorrelation on mean flowering intensity

11.3 Omega: The magnitude of the effect of autocorrelation on mean flowering intensity

11.4 Gamma: The variance of the effect of autocorrelation on mean flowering intensity

11.5 Beta: The effect of elevation on flowering presence

Still TODO

To make the graph interesting, take the difference in the minimum elevation and the max elevation and express the effect in days

11.6 Estimated Inensity

11.7 Effect of autocorrelation

11.8 Decay in autocorrelation effect

12 Model Fit

12.1 Bayesian pvalue

## # A tibble: 1 x 2
##   Model      p
##   <chr>  <dbl>
## 1 julian     0

12.2 Overall

12.3 By Species

Zoom in #Prediction

12.4 Predicted Phenology